package com.lianbang.pharmacy.vm

import androidx.lifecycle.MutableLiveData
import cn.ubest.mvvmcore.base.BaseViewModel
import cn.ubest.mvvmcore.interfaces.RequestHandler1Impl
import com.lianbang.pharmacy.bean.SignBean
import com.lianbang.pharmacy.bean.UserSignBean
import com.lianbang.pharmacy.model.UserModel

/**
 * Created by maoqi on 2020/12/30.
 */
class SignVM :BaseViewModel<UserModel>(){
    val mSignLiveData by lazy {
        MutableLiveData<Any>()
    }


    fun userSignInfo() {
        requestWithLife(object : RequestHandler1Impl<UserSignBean>(this) {
            override suspend fun request1(): UserSignBean {
                return mModel.userSignInfo().resolveWrapper()
            }

            override fun onSuccess(t: UserSignBean) {
                mSignLiveData.postValue(t)
            }
        })
    }

    fun sign() {
        requestWithLife(object : RequestHandler1Impl<SignBean>(this) {
            override suspend fun request1(): SignBean {
                return mModel.sign().resolveWrapper()
            }

            override fun onSuccess(t: SignBean) {
                mSignLiveData.postValue(t)
            }
        })
    }
}